module MC.View {
	export class MyOrderList {
		public constructor() {
			this.init();
		}
		private list: MC.Page;
		private init() {
			this.list = new MC.Page("#jobDetail", '/api/my/pub/order-get', {},
				(resData: any, page: any) => {
					if (page == 0 && resData.length == 0) {
						var h = '';
						h += '<table class="toJobShow">';
						h += '<tr>';
						h += '<td colspan="2" style="text-align:center;">没有信息</td>';
						h += '</tr>';
						h += '</table>';
						$('#jobDetail').html(h);
						$('.btn').hide();
						return;
					} else {
						this.order_ul('#jobDetail .myhuodanUl', resData);
					}
				});
			this.list.init();
			this.onClick();
		}
		private order_ul(jselect: string, list: any) {
			let jq = $(jselect);
			for (let i = 0; i < list.length; i++) {
				let obj = list[i];
				//<a class="buttonred button delete none">下架</a>
				let edit=`<a class="button 编辑" href="/h5/index/addOrder.html?id=`+obj.id+`">编辑</a>`;
				if(obj.count>0){
					edit='';
				}
				let li = `
				
				<li class="li">
                <div class="hdcontent clearfix">
                    <a class="htop clearfix" href="/h5/order/orderShow.html?id=`+obj.id+`">
                        <p class="name">`+obj.name+`<span class="bond">`+obj.bond+`</span></p>
                        <span class="qiangdanrenshu">接单人数:`+obj.count+`</span>
						<span class="timedate">交货时间:`+obj.period+`</span>
                            <span class="status_str">`+obj.status_src+`</span>
                    </a>
                    <div class="hcontent clearfix">
                        <a class="imgDiv" href="/h5/order/orderShow.html?id=`+obj.id+`">
                            <img src="`+obj.img+`"
                                 class="img"/>
                        </a>
                        <div class="spanDiv">
                            <span class="cate">`+obj.cate+`</span> 
                            <p class="detail">`+obj.detail+`</p>
                        </div>
                    </div>
                    
                    <div class="kbuttonDiv clearfix">
                        <div class="kbuttonCon">
                            <a class="button xuanze" href="/h5/order/orderXuanze.html?bale=`+obj.id+`">查看工厂</a> 
                             `+edit+`
                        </div>
                    </div>
                    
                </div>
            </li>
				
				`;
				jq.append(li);
			}
		}
		private onClick(){

		}
	}
}